from selenium.webdriver.common.by import By

from base.BackgroundBase.back_base import BasePage, BaseHandle


class HomePage(BasePage):
    def __init__(self):
        super().__init__()
        self.mall = By.XPATH, "//*[@class='nc-row']/li[2]/a"
        self.list = By.XPATH, "//*[@class='active']/a"

    def find_mall_btn(self):
        return self.get_element(self.mall)

    def find_list(self):
        return self.get_element(self.list)


class HomeHandle(BaseHandle):
    def __init__(self):
        self.home_page = HomePage()

    def click_mall_btn(self):
        self.home_page.find_mall_btn().click()

    def click_list(self):
        self.home_page.find_list().click()


class HomeProxy:
    def __init__(self):
        self.home_handle = HomeHandle()

    def go_product_page(self):
        self.home_handle.click_mall_btn()
        self.home_handle.click_list()
